﻿using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElsProp.Model
{
    /// <summary>
    /// 单件装备
    /// </summary>
    public class PropModel:ObservableObject
    {
        /// <summary>
        /// 套装
        /// </summary>
        private string _Suit;
        public string Suit { get => _Suit; set { SetProperty(ref _Suit, value); PropModelName = Suit + Name; } }

        /// <summary>
        /// 套装
        /// </summary>
        private string _SuitName;
        public string SuitName { get => _SuitName; set => SetProperty(ref _SuitName, value); }
        /// <summary>
        /// 名称
        /// </summary>
        private string _Name;
        public string Name { get => _Name; set { SetProperty(ref _Name, value); PropModelName = Suit + Name; } }

        private string _PropModelName;
        /// <summary>
        /// 装备名称
        /// </summary>
        public string PropModelName { get => _PropModelName; set => SetProperty(ref _PropModelName, value); }
        /// <summary>
        /// 属性
        /// </summary>
        private ObservableCollection<ItemProperties> _Properties;
        public ObservableCollection<ItemProperties> Properties { get => _Properties; set { SetProperty(ref _Properties, value);SubPropertiesStr(); } }
        /// <summary>
        /// 套装属性
        /// </summary>
        private ObservableCollection<ItemProperties> _SuitProperties;
        public ObservableCollection<ItemProperties> SuitProperties { get => _SuitProperties; set => SetProperty(ref _SuitProperties, value); }

        /// <summary>
        /// 部位
        /// </summary>
        private EnumZhuangBeiLan _BuWei;
        public EnumZhuangBeiLan BuWei { get => _BuWei; set => SetProperty(ref _BuWei, value); }

        /// <summary>
        /// 
        /// </summary>
        public string guid {  get; set; }
        /// <summary>
        /// 
        /// </summary>
        private string _PropertiesStr;
        /// <summary>
        /// 
        /// </summary>
        public string PropertiesStr { get => _PropertiesStr; set => SetProperty(ref _PropertiesStr, value); }

        public void SubPropertiesStr()
        {
            PropertiesStr = "";
            if (Properties!=null)
            {
                foreach (var item in Properties)
                {
                    if (PropertiesStr!="")
                    {
                        PropertiesStr += " ";
                    }
                    if (item.PropertiesName.Contains("{0}"))
                    {
                        PropertiesStr += string.Format(item.PropertiesName, item.PropertiesValue);
                    }
                    else
                    {
                        PropertiesStr += string.Format(item.PropertiesName+item.PropertiesValue);
                    }
                }
            }
        }
    }

}
